package Model;

import java.io.Serializable;

import Messaging.Notification;
import Messaging.NotificationManager;

/*
 * @author Roch San Buenaventura
 */

public class UpgradeablePropertyLevel2 extends UpgradeablePropertyState implements Serializable
{
	
	private static UpgradeablePropertyLevel2 INSTANCE = null;
	final static long serialVersionUID = 224;
	
	protected UpgradeablePropertyLevel2() 
	{

	}
	
	public static UpgradeablePropertyState Instance() 
	{
		if (INSTANCE == null) {
			INSTANCE = new UpgradeablePropertyLevel2();
		}
		
		return INSTANCE;
	}

	public void landOn(Player player, PropertySpace property)
	{
		property.getOwner().collectRent(property.getRentValues()[2], player);
	}
	
	protected void renovate(UpgradeablePropertySpace p) 
	{
		p.changeState(UpgradeablePropertyLevel3.Instance());
		NotificationManager.getInstance().notifyObservers
		(Notification.UPDATE_PROPERTIES, new Player(p.getOwner()));
	}
	
	protected void downgrade(UpgradeablePropertySpace p)
	{
		p.changeState(UpgradeablePropertyLevel1.Instance());
		NotificationManager.getInstance().notifyObservers
		(Notification.UPDATE_PROPERTIES, new Player(p.getOwner()));
	}
	
	protected boolean isUpgradeable(UpgradeablePropertySpace p)
	{
		return p.getOwner().monopolyUpgradeValid(p);
	}
	
	protected boolean isDowngradeable(UpgradeablePropertySpace p)
	{
		return p.getOwner().monopolyDowngradeValid(p);
	}
	
	protected String getNameAndStatus()
	{
		return " (Level 2)";
	}
	
	public int getLevel()
	{
		return 2;
	}
	
	public String toString() 
	{
		return "UpgradeablePropertyLevel2";
	}
}
